﻿@using Cinema_Ticketing_System.Models;
@{
    ViewBag.Title = "View";
    Layout = "~/Views/Shared/CinemaAdminLayoutPage.cshtml";
}

@section styles{
    <style>
        #bigbox table {
            margin-top: 10px;
            width: 1000px;
        }

            #bigbox table tr td:first-child {
                text-align: center;
                font-size: 18px;
                font-weight: bolder;
            }

            #bigbox table tr td select {
                width: 200px;
            }
    </style>
}
<div id="bigbox" class="container">
    <table class="table table-bordered">
        <tr>
            <td>影片名称:</td>
            <td><input type="text"  id="filmname"/></td>
        </tr>
        <tr>
            <td>地区:</td>
            <td><input type="text"  id="filmarea"/></td>
        </tr>
        <tr>
            <td>片长:</td>
            <td><input type="text"  id="duration"/></td>
        </tr>
        <tr>
            <td>上映时间:</td>
            <td><input type="text"  id="release_time"/></td>
        </tr>
        <tr>
            <td>主演:</td>
            <td><input type="text"  id="star"/></td>
        </tr>
        <tr>
            <td>类型:</td>
            <td>
                <select name="area" class="form-control" id="area">
                    <option value=-99>--请选择分类--</option>
                    @foreach (var item in ViewBag.listtype as List<type_table>)
                    {
                        <option value="@item.typeid"  id="typeid">@item.filmtype</option>
                    }
                </select>
            </td>
        </tr>
        <tr>
            <td>语言:</td>
            <td><input type="text"  id="filmlanguage"/></td>
        </tr>
        <tr>
            <td>影片简介:</td>
            <td><textarea  id="brief_introduction"></textarea></td>
        </tr>
        <tr>
            <td>图片地址:</td>
            <td><input type="file"  id="cover"/><button>添加图片</button> </td>
        </tr>
        <tr>
            <td>单个票价:</td>
            <td><input type="text"  id="price"/>&nbsp;元</td>
        </tr>
        <tr>
            <td colspan="2"><button class="btn btn-primary" id="btnadd">添加影片</button> </td>
        </tr>
    </table>
</div>

@section scripts
{
    <script>

        $(function() {

            $("#btnadd").click(function () {

                var msg = {
                    filmname: $("#filmname").val(),
                    filmarea: $("#filmarea").val(),
                    duration: $("#duration").val(),
                    release_time: $("#release_time").val(),
                    typeid: $("#typeid").val(),
                    filmlanguage: $("#filmlanguage").val(),
                    star: $("#star").val(),
                    brief_introduction: $("#brief_introduction").val(),
                    cover: $("#cover").val(),
                    price: $("#price").val(),
                }
                console.log(msg);
                $.ajax({
                    url: "/Admin/AddFilm",
                    type: "POST",
                    data: msg,
                    success: function (data) {
                        if (data == "添加成功")
                            alert(data);
                    },
                    error: function (data) {
                        alert("erroer");
                    },
                })
            })
        })
    </script>
    }

